﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DreamBox.Admin.Posts
{
    public partial class Reply : BLL.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["PageWhere"] = Request.QueryString["PostsID"] != null ? "PostsID=" + Request.QueryString["PostsID"] : "";
            }
            BindList(ViewState["PageWhere"].ToString());
        }
        void BindList(string where)
        {
            PagerList.TableName = "dbox_v_replyposts";
            PagerList.FldName = "ReplyID";
            PagerList.PagerControls = RepeaterList;
            PagerList.PageSize = 10;
            PagerList.Where = where;
            PagerList.Order = 1;
        }
        protected void LinkBtnDelete_Click(object sender, EventArgs e)
        {
            DAL.Posts.Reply posts = new DAL.Posts.Reply();

            CheckBox box = null;

            foreach (RepeaterItem item in RepeaterList.Items)
            {
                box = item.FindControl("CheckBoxSelect") as CheckBox;
                if (box != null && box.Checked)
                {
                  posts.Delete(int.Parse(box.ToolTip));
                }
            }
            BLL.Admin.Tips.DetailedTips(this, "操作成功!", "/Posts/Reply.aspx", "1");
        }
        //根据用户名查找
        protected void btnSelectClassName_Click(object sender, EventArgs e)
        {
            string where = "";
            if (UserName.Text.Trim() != "")
            {
                where = "UserName='" + UserName.Text.Trim() + "'";
                ViewState["PageWhere"] = where;
            }
            PagerList.Where = where;
            PagerList.BindPage(1);
        }
    }
}